<?php
// +----------------------------------------------------------------------
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
// +----------------------------------------------------------------------
// | Copyright (c) 2006~2017 http://thinkphp.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: 李邦琦 <1536549251@qq.com>
// +----------------------------------------------------------------------

namespace app\crm\controller;
use think\Loader;
use think\Cache;

class Extension extends CrmController
{
    /**
     * extensionList
     */
    public function extensionList()
    {
        $menuname = "Extension";
        $p_menuname = $_SESSION['menu'][$menuname]; //父菜单
        $priv = $_SESSION["user_priv"][$p_menuname][$menuname];     
        $this->assign("priv",$priv);
        // 模板输出
        return $this->fetch('extensionList');
    }


    /**
     * 加载系统参数数据
     * @return json 系统参数数据
     */
    public function extensionListData()
    {
        $arrData = Loader::model('Extension')->extensionListData();
        echo json_encode($arrData);
    }


    /**
     * 渲染模板addSystemSet
     */
    public function addExtension()
    {
        $menuname = "Extension";
        $p_menuname = $_SESSION['menu'][$menuname]; //父菜单
        $priv = $_SESSION["user_priv"][$p_menuname][$menuname];     
        $this->assign("priv",$priv);
        // 模板输出
        return $this->fetch('addExtension');
    }


    /**
     * 新增系统参数
     */
    public function insertExtension ()
    {
        $data = $_REQUEST;
        Loader::model('Extension')->insertExtension($data);
    }


    /**
     * 删除系统参数
     */
    public function delExtension ()
    {
        $id = $_REQUEST['id'];
        Loader::model('Extension')->delExtension($id);
    }


    /**
     * 渲染模板editSystemSet
     */
    public function editExtension()
    {
        $menuname = "Extension";
        $p_menuname = $_SESSION['menu'][$menuname]; //父菜单
        $priv = $_SESSION["user_priv"][$p_menuname][$menuname];     
        $this->assign("priv",$priv);
        $id = $_GET['id'];
        $data = Loader::model('Extension')->getExtension($id);
        $this->assign('data', $data);
        // 模板输出
        return $this->fetch('editExtension');
    }


    /**
     * 编辑系统参数
     */
    public function updateExtension ()
    {
        $data = $_REQUEST;
        Loader::model('Extension')->updateExtension($data);
    }



}